package com.donleo.user.config;

import org.springframework.cloud.client.loadbalancer.LoadBalanced;
import org.springframework.cloud.netflix.ribbon.RibbonClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.core.annotation.Order;
import org.springframework.web.client.RestTemplate;

/**
 * @author liangd
 * @since 2021-01-11 18:53
 * RestTemplate 配置
 */
@Configuration
public class RibbonConfig {
    /**
     * 使用@LoadBalanced注解赋予RestTemplate负载均衡的能力
     * 默认线性轮询的方式
     */
    @Bean
    @LoadBalanced
    @Order(2)
    public RestTemplate restTemplate(){
        return new RestTemplate();
    }
}
